﻿//***********************************************************************
// Assembly         : IGolovkine.AoA.Core
// Author           : Ilia
// Created          : 06-11-2011
//
// Last Modified By : Ilia
// Last Modified On : 06-11-2011
// Description      : 
//
// Copyright        : (c) Microsoft. All rights reserved.
//***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IGolovkine.AoA.BinarySerialization;

namespace IGolovkine.AoA.Tcp
{
    [Serializable]
    public abstract class TcpConnectionMessage : TcpMessage 
    {
        private readonly CorrelationId _connectionId;

        protected TcpConnectionMessage(CorrelationId connectionId) 
        {
            _connectionId = connectionId;
        }

        protected TcpConnectionMessage(ISlimBinaryReader reader) : base(reader)
        {
            _connectionId = reader.ReadObject<CorrelationId>();
        }

        public CorrelationId ConnectionId
        {
            get { return _connectionId; }
        }

        public override void Serialize(ISlimBinaryWriter writer)
        {
            base.Serialize(writer);
            writer.WriteObject(_connectionId);
        }
    }
}
